<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />

  <title>Class: AdminController</title>

  <link rel="stylesheet" href="./rdoc.css" type="text/css" media="screen" />

  <script src="./js/jquery.js" type="text/javascript" charset="utf-8"></script>
  <script src="./js/thickbox-compressed.js" type="text/javascript" charset="utf-8"></script>
  <script src="./js/quicksearch.js" type="text/javascript" charset="utf-8"></script>
  <script src="./js/darkfish.js" type="text/javascript" charset="utf-8"></script>

</head>
<body id="top" class="class">

  <div id="metadata">
    <div id="home-metadata">
      <div id="home-section" class="section">
        <h3 class="section-header">
          <a href="./index.html">Home</a>
          <a href="./index.html#classes">Classes</a>
          <a href="./index.html#methods">Methods</a>
        </h3>
      </div>
    </div>

    <div id="file-metadata">
      <div id="file-list-section" class="section">
        <h3 class="section-header">In Files</h3>
        <div class="section-body">
          <ul>
          
            <li><a href="./app/controllers/admin_controller_rb.html?TB_iframe=true&amp;height=550&amp;width=785"
              class="thickbox" title="app/controllers/admin_controller.rb">app/controllers/admin_controller.rb</a></li>
          
          </ul>
        </div>
      </div>

      
    </div>

    <div id="class-metadata">
      
      <!-- Parent Class -->
      <div id="parent-class-section" class="section">
        <h3 class="section-header">Parent</h3>
        
        <p class="link"><a href="ApplicationController.html">ApplicationController</a></p>
        
      </div>
      

      

      

      
      <!-- Method Quickref -->
      <div id="method-list-section" class="section">
        <h3 class="section-header">Methods</h3>
        <ul class="link-list">
          
          <li><a href="#method-i-change_password">#change_password</a></li>
          
          <li><a href="#method-i-change_password_form">#change_password_form</a></li>
          
          <li><a href="#method-i-configuration">#configuration</a></li>
          
          <li><a href="#method-i-contact_us">#contact_us</a></li>
          
          <li><a href="#method-i-get_latest_time">#get_latest_time</a></li>
          
          <li><a href="#method-i-get_latest_updates">#get_latest_updates</a></li>
          
          <li><a href="#method-i-home">#home</a></li>
          
          <li><a href="#method-i-index">#index</a></li>
          
          <li><a href="#method-i-login">#login</a></li>
          
          <li><a href="#method-i-logout">#logout</a></li>
          
          <li><a href="#method-i-required_apps">#required_apps</a></li>
          
          <li><a href="#method-i-send_feedback">#send_feedback</a></li>
          
          <li><a href="#method-i-send_report_bug">#send_report_bug</a></li>
          
        </ul>
      </div>
      

      
    </div>

    <div id="project-metadata">
      
      
      <div id="fileindex-section" class="section project-section">
        <h3 class="section-header">Files</h3>
        <ul>
        
          <li class="file"><a href="./doc/README_FOR_APP.html">README_FOR_APP</a></li>
        
        </ul>
      </div>
      

      <div id="classindex-section" class="section project-section">
        <h3 class="section-header">Class/Module Index
          <span class="search-toggle"><img src="./images/find.png"
            height="16" width="16" alt="[+]"
            title="show/hide quicksearch" /></span></h3>
        <form action="#" method="get" accept-charset="utf-8" class="initially-hidden">
        <fieldset>
          <legend>Quicksearch</legend>
          <input type="text" name="quicksearch" value=""
            class="quicksearch-field" />
        </fieldset>
        </form>

        <ul class="link-list">
        
          <li><a href="./Analytics.html">Analytics</a></li>
        
          <li><a href="./Analytics/Database.html">Analytics::Database</a></li>
        
          <li><a href="./Analytics/ResourceUsage.html">Analytics::ResourceUsage</a></li>
        
          <li><a href="./Analytics/Throughput.html">Analytics::Throughput</a></li>
        
          <li><a href="./Analytics/Url.html">Analytics::Url</a></li>
        
          <li><a href="./Analytics/UrlBreakup.html">Analytics::UrlBreakup</a></li>
        
          <li><a href="./ActionView.html">ActionView</a></li>
        
          <li><a href="./ActionView/Helpers.html">ActionView::Helpers</a></li>
        
          <li><a href="./ActionView/Helpers/AssetTagHelper.html">ActionView::Helpers::AssetTagHelper</a></li>
        
          <li><a href="./AdminController.html">AdminController</a></li>
        
          <li><a href="./AdminHelper.html">AdminHelper</a></li>
        
          <li><a href="./App.html">App</a></li>
        
          <li><a href="./AppException.html">AppException</a></li>
        
          <li><a href="./AppTimeSample.html">AppTimeSample</a></li>
        
          <li><a href="./ApplicationController.html">ApplicationController</a></li>
        
          <li><a href="./ApplicationHelper.html">ApplicationHelper</a></li>
        
          <li><a href="./ApplicationSpecification.html">ApplicationSpecification</a></li>
        
          <li><a href="./ApplicationSpecificationController.html">ApplicationSpecificationController</a></li>
        
          <li><a href="./ApplicationSpecificationHelper.html">ApplicationSpecificationHelper</a></li>
        
          <li><a href="./Control.html">Control</a></li>
        
          <li><a href="./ExceptionDetail.html">ExceptionDetail</a></li>
        
          <li><a href="./ExceptionsController.html">ExceptionsController</a></li>
        
          <li><a href="./ExceptionsHelper.html">ExceptionsHelper</a></li>
        
          <li><a href="./GraphController.html">GraphController</a></li>
        
          <li><a href="./GraphHelper.html">GraphHelper</a></li>
        
          <li><a href="./Headers.html">Headers</a></li>
        
          <li><a href="./HeadersController.html">HeadersController</a></li>
        
          <li><a href="./HeadersHelper.html">HeadersHelper</a></li>
        
          <li><a href="./MailSpecification.html">MailSpecification</a></li>
        
          <li><a href="./MailSpecificationController.html">MailSpecificationController</a></li>
        
          <li><a href="./MailSpecificationHelper.html">MailSpecificationHelper</a></li>
        
          <li><a href="./Mailer.html">Mailer</a></li>
        
          <li><a href="./Object.html">Object</a></li>
        
          <li><a href="./PseudoModel.html">PseudoModel</a></li>
        
          <li><a href="./ResourceUsage.html">ResourceUsage</a></li>
        
          <li><a href="./SCGI.html">SCGI</a></li>
        
          <li><a href="./ServerSpecification.html">ServerSpecification</a></li>
        
          <li><a href="./ServerSpecificationController.html">ServerSpecificationController</a></li>
        
          <li><a href="./ServerSpecificationHelper.html">ServerSpecificationHelper</a></li>
        
          <li><a href="./SignalHelper.html">SignalHelper</a></li>
        
          <li><a href="./UrlBreakupTimeSample.html">UrlBreakupTimeSample</a></li>
        
          <li><a href="./UrlTimeSample.html">UrlTimeSample</a></li>
        
          <li><a href="./User.html">User</a></li>
        
          <li><a href="./YAMLConfig.html">YAMLConfig</a></li>
        
          <li><a href="./YAMLWriter.html">YAMLWriter</a></li>
        
        </ul>
        <div id="no-class-search-results" style="display: none;">No matching classes.</div>
      </div>

      
    </div>
  </div>

  <div id="documentation">
    <h1 class="class">AdminController</h1>

    <div id="description" class="description">
      
<p>This controller deals with all the actions related to the user handling and
application configuration.</p>

    </div><!-- description -->

    
    
    
    <div id="5Buntitled-5D" class="documentation-section">
      

      

      

      

      <!-- Methods -->
      
      <div id="public-instance-method-details" class="method-section section">
        <h3 class="section-header">Public Instance Methods</h3>

      
        <div id="change_password-method" class="method-detail ">
          <a name="method-i-change_password"></a>

          
          <div class="method-heading">
            <span class="method-name">change_password</span><span
              class="method-args">()</span>
            <span class="method-click-advice">click to toggle source</span>
          </div>
          

          <div class="method-description">
            
            <p>The action is to change the password of the admin panel user.</p>
            

            
            <div class="method-source-code" id="change_password-source">
<pre>
<span class="ruby-comment"># File app/controllers/admin_controller.rb, line 96</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">change_password</span>
  <span class="ruby-identifier">set_application_name</span>
  <span class="ruby-identifier">password_changed</span> = <span class="ruby-keyword">false</span>
  <span class="ruby-identifier">users</span> = <span class="ruby-constant">YAML</span><span class="ruby-operator">::</span><span class="ruby-identifier">load_file</span>(<span class="ruby-constant">USERS_FILE_PATH</span>) <span class="ruby-keyword">rescue</span> <span class="ruby-keyword">nil</span>
  <span class="ruby-identifier">users</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">user</span><span class="ruby-operator">|</span>
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">user</span>[<span class="ruby-string">'user_name'</span>] <span class="ruby-operator">==</span> <span class="ruby-identifier">session</span>[<span class="ruby-value">:user</span>] <span class="ruby-operator">&amp;&amp;</span>  <span class="ruby-identifier">user</span>[<span class="ruby-string">'password'</span>] <span class="ruby-operator">==</span> <span class="ruby-constant">Digest</span><span class="ruby-operator">::</span><span class="ruby-constant">MD5</span>.<span class="ruby-identifier">hexdigest</span>(<span class="ruby-identifier">params</span>[<span class="ruby-value">:password</span>][<span class="ruby-value">:old</span>]) <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">params</span>[<span class="ruby-value">:password</span>][<span class="ruby-value">:new</span>] <span class="ruby-operator">==</span> <span class="ruby-identifier">params</span>[<span class="ruby-value">:password</span>][<span class="ruby-value">:confirm</span>] <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">params</span>[<span class="ruby-value">:password</span>][<span class="ruby-value">:new</span>].<span class="ruby-identifier">length</span> <span class="ruby-operator">&gt;</span> <span class="ruby-value">5</span> 
      <span class="ruby-identifier">user</span>[<span class="ruby-string">'password'</span>] = <span class="ruby-constant">Digest</span><span class="ruby-operator">::</span><span class="ruby-constant">MD5</span>.<span class="ruby-identifier">hexdigest</span>(<span class="ruby-identifier">params</span>[<span class="ruby-value">:password</span>][<span class="ruby-value">:new</span>])
      <span class="ruby-identifier">password_changed</span> = <span class="ruby-keyword">true</span>
      <span class="ruby-keyword">break</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">password_changed</span>
    <span class="ruby-constant">YAMLWriter</span>.<span class="ruby-identifier">write</span>(<span class="ruby-identifier">users</span>, <span class="ruby-constant">USERS_FILE_PATH</span>, <span class="ruby-constant">YAMLConfig</span><span class="ruby-operator">::</span><span class="ruby-constant">USER</span>)
    <span class="ruby-identifier">reset_session</span>
    <span class="ruby-identifier">flash</span>[<span class="ruby-value">:notice</span>] = <span class="ruby-constant">PASSWORD_CHANGED</span>
    <span class="ruby-identifier">redirect_to</span> <span class="ruby-identifier">root_path</span>
  <span class="ruby-keyword">else</span>
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">params</span>[<span class="ruby-value">:password</span>][<span class="ruby-value">:new</span>].<span class="ruby-identifier">length</span> <span class="ruby-operator">&lt;</span> <span class="ruby-value">6</span>
      <span class="ruby-identifier">flash</span>[<span class="ruby-value">:notice</span>] = <span class="ruby-constant">WRONG_PASSWORD2</span>
    <span class="ruby-keyword">else</span> 
      <span class="ruby-identifier">flash</span>[<span class="ruby-value">:notice</span>] = <span class="ruby-constant">WRONG_PASSWORD1</span>
    <span class="ruby-keyword">end</span>
    <span class="ruby-identifier">render</span> <span class="ruby-value">:action</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-string">'change_password_form'</span>
    <span class="ruby-comment">#TODO : This message is to be made more specific for old password and confirm password.</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
            </div><!-- change_password-source -->
            
          </div>

          

          
        </div><!-- change_password-method -->

      
        <div id="change_password_form-method" class="method-detail ">
          <a name="method-i-change_password_form"></a>

          
          <div class="method-heading">
            <span class="method-name">change_password_form</span><span
              class="method-args">()</span>
            <span class="method-click-advice">click to toggle source</span>
          </div>
          

          <div class="method-description">
            
            <p>This method is used to render the Admin Panel Settings Page.</p>
            

            
            <div class="method-source-code" id="change_password_form-source">
<pre>
<span class="ruby-comment"># File app/controllers/admin_controller.rb, line 124</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">change_password_form</span>
  <span class="ruby-identifier">set_application_name</span>
<span class="ruby-keyword">end</span></pre>
            </div><!-- change_password_form-source -->
            
          </div>

          

          
        </div><!-- change_password_form-method -->

      
        <div id="configuration-method" class="method-detail ">
          <a name="method-i-configuration"></a>

          
          <div class="method-heading">
            <span class="method-name">configuration</span><span
              class="method-args">()</span>
            <span class="method-click-advice">click to toggle source</span>
          </div>
          

          <div class="method-description">
            
            <p>This function is to get the details of config file for configuration page.
This page contains the server settings and the application settings.</p>
            

            
            <div class="method-source-code" id="configuration-source">
<pre>
<span class="ruby-comment"># File app/controllers/admin_controller.rb, line 53</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">configuration</span>                     
  <span class="ruby-ivar">@info</span>= <span class="ruby-constant">YAML</span><span class="ruby-operator">::</span><span class="ruby-identifier">load_file</span>(<span class="ruby-constant">CONFIG_FILE_PATH</span>)    <span class="ruby-keyword">rescue</span> <span class="ruby-keyword">nil</span>
  <span class="ruby-ivar">@applications</span> = <span class="ruby-constant">App</span>.<span class="ruby-identifier">get_all</span>(<span class="ruby-value">1</span>)
  <span class="ruby-ivar">@ssl_spec</span> = <span class="ruby-constant">Hash</span>[<span class="ruby-value">:certificate_path</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">params</span>[<span class="ruby-value">:ssl</span>][<span class="ruby-value">:certificate_path</span>],
    <span class="ruby-value">:key_path</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">params</span>[<span class="ruby-value">:ssl</span>][<span class="ruby-value">:key_path</span>],
    <span class="ruby-value">:port</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">params</span>[<span class="ruby-value">:ssl</span>][<span class="ruby-value">:port</span>]] <span class="ruby-keyword">if</span> <span class="ruby-identifier">params</span>[<span class="ruby-value">:ssl</span>]
  <span class="ruby-ivar">@sendmail_old</span> = <span class="ruby-identifier">params</span>[<span class="ruby-value">:sendmail</span>] <span class="ruby-keyword">if</span> <span class="ruby-identifier">params</span>[<span class="ruby-value">:sendmail</span>]
  <span class="ruby-ivar">@smtp_old</span> = <span class="ruby-identifier">params</span>[<span class="ruby-value">:smtp</span>] <span class="ruby-keyword">if</span> <span class="ruby-identifier">params</span>[<span class="ruby-value">:smtp</span>]
  <span class="ruby-identifier">set_application_name</span>
<span class="ruby-keyword">end</span></pre>
            </div><!-- configuration-source -->
            
          </div>

          

          
        </div><!-- configuration-method -->

      
        <div id="contact_us-method" class="method-detail ">
          <a name="method-i-contact_us"></a>

          
          <div class="method-heading">
            <span class="method-name">contact_us</span><span
              class="method-args">()</span>
            <span class="method-click-advice">click to toggle source</span>
          </div>
          

          <div class="method-description">
            
            <p>This method is used to render the report_bug, feedback and <a
href="AdminController.html#method-i-contact_us">contact_us</a> form on the
basis of <a href="http://:form_name">params</a></p>
            

            
            <div class="method-source-code" id="contact_us-source">
<pre>
<span class="ruby-comment"># File app/controllers/admin_controller.rb, line 162</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">contact_us</span>
  <span class="ruby-identifier">flash</span>[<span class="ruby-value">:notice</span>] = <span class="ruby-constant">Mailer</span>.<span class="ruby-identifier">check_smtp_mail_settings</span>
  <span class="ruby-ivar">@rb</span> = {<span class="ruby-value">:name</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-string">&quot;&quot;</span> ,<span class="ruby-value">:email</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-string">&quot;&quot;</span>,<span class="ruby-value">:subject</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-string">&quot;&quot;</span>,<span class="ruby-value">:description</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-string">&quot;&quot;</span>}
  <span class="ruby-ivar">@fb</span> = {<span class="ruby-value">:name</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-string">&quot;&quot;</span> ,<span class="ruby-value">:email</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-string">&quot;&quot;</span>,<span class="ruby-value">:message</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-string">&quot;&quot;</span>}
  <span class="ruby-keyword">case</span> <span class="ruby-identifier">params</span>[<span class="ruby-value">:form_name</span>]
    <span class="ruby-keyword">when</span> <span class="ruby-string">&quot;report_bug&quot;</span>
      <span class="ruby-identifier">render</span> <span class="ruby-value">:partial</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-string">&quot;report_bug_partial&quot;</span>
    <span class="ruby-keyword">when</span> <span class="ruby-string">&quot;feedback&quot;</span>
      <span class="ruby-identifier">render</span> <span class="ruby-value">:partial</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-string">&quot;feedback_partial&quot;</span>
    <span class="ruby-keyword">else</span>
      <span class="ruby-identifier">render</span> <span class="ruby-string">&quot;contact_us&quot;</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
            </div><!-- contact_us-source -->
            
          </div>

          

          
        </div><!-- contact_us-method -->

      
        <div id="get_latest_time-method" class="method-detail ">
          <a name="method-i-get_latest_time"></a>

          
          <div class="method-heading">
            <span class="method-name">get_latest_time</span><span
              class="method-args">()</span>
            <span class="method-click-advice">click to toggle source</span>
          </div>
          

          <div class="method-description">
            
            <p>This method is to return the server time. The method refreshes the time
after every minute.</p>
            

            
            <div class="method-source-code" id="get_latest_time-source">
<pre>
<span class="ruby-comment"># File app/controllers/admin_controller.rb, line 147</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">get_latest_time</span>
  <span class="ruby-identifier">render</span> <span class="ruby-value">:text</span> =<span class="ruby-operator">&gt;</span>  <span class="ruby-constant">Time</span>.<span class="ruby-identifier">now</span>.<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&quot;%d %b %Y %H:%M&quot;</span>)
<span class="ruby-keyword">end</span></pre>
            </div><!-- get_latest_time-source -->
            
          </div>

          

          
        </div><!-- get_latest_time-method -->

      
        <div id="get_latest_updates-method" class="method-detail ">
          <a name="method-i-get_latest_updates"></a>

          
          <div class="method-heading">
            <span class="method-name">get_latest_updates</span><span
              class="method-args">()</span>
            <span class="method-click-advice">click to toggle source</span>
          </div>
          

          <div class="method-description">
            
            <p>Update all the dynamic values on home page</p>
            

            
            <div class="method-source-code" id="get_latest_updates-source">
<pre>
<span class="ruby-comment"># File app/controllers/admin_controller.rb, line 129</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">get_latest_updates</span>
  <span class="ruby-identifier">server_usage</span> = <span class="ruby-constant">ResourceUsage</span>.<span class="ruby-identifier">get_latest_for_server</span>
  <span class="ruby-identifier">apps_usage</span> = <span class="ruby-constant">ResourceUsage</span>.<span class="ruby-identifier">get_latest_for_apps_with_exceptions</span>
  <span class="ruby-identifier">str</span> = <span class="ruby-node">&quot;&lt;script&gt;
      loadDivs(new Array('server_cpu_usage','#{&quot;%.2f&quot; % server_usage[0]}','server_memory_usage','#{&quot;%.2f&quot; % (server_usage[1].to_f/1024)}'&quot;</span>

       <span class="ruby-identifier">apps_usage</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">key</span>, <span class="ruby-identifier">val</span><span class="ruby-operator">|</span>
        <span class="ruby-keyword">unless</span> <span class="ruby-identifier">key</span>[<span class="ruby-string">&quot; &quot;</span>] <span class="ruby-keyword">or</span> <span class="ruby-identifier">key</span> <span class="ruby-operator">==</span> <span class="ruby-string">'static-worker'</span>
          <span class="ruby-identifier">str</span><span class="ruby-operator">&lt;&lt;</span><span class="ruby-node">&quot;,'#{key}_cpu','#{&quot;%.2f&quot; % val[0]}','#{key}_memory','#{&quot;%.2f&quot; % (val[1].to_f/1024)}','#{key}_exception','#{val[2]}'&quot;</span>
        <span class="ruby-keyword">end</span>
      <span class="ruby-keyword">end</span>
      <span class="ruby-identifier">str</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-string">&quot;));&lt;/script&gt;&quot;</span>

  <span class="ruby-identifier">render</span> <span class="ruby-value">:text</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">str</span>
<span class="ruby-keyword">end</span></pre>
            </div><!-- get_latest_updates-source -->
            
          </div>

          

          
        </div><!-- get_latest_updates-method -->

      
        <div id="home-method" class="method-detail ">
          <a name="method-i-home"></a>

          
          <div class="method-heading">
            <span class="method-name">home</span><span
              class="method-args">()</span>
            <span class="method-click-advice">click to toggle source</span>
          </div>
          

          <div class="method-description">
            
            <p>This action is for displaying the first page i.e Home page of the Admin
Panel. This page contains the server snapshot(i.e. its cpu and memory
usgae)  and the list of application deployed on the server with its cpu and
memory usgae.</p>
            

            
            <div class="method-source-code" id="home-source">
<pre>
<span class="ruby-comment"># File app/controllers/admin_controller.rb, line 44</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">home</span>
  <span class="ruby-ivar">@info</span> = <span class="ruby-constant">YAML</span><span class="ruby-operator">::</span><span class="ruby-identifier">load_file</span>(<span class="ruby-constant">CONFIG_FILE_PATH</span>) <span class="ruby-keyword">rescue</span> <span class="ruby-keyword">nil</span> <span class="ruby-comment">#To get the data of yaml file into yaml object</span>
  <span class="ruby-ivar">@server_resource_usage</span> = <span class="ruby-constant">ResourceUsage</span>.<span class="ruby-identifier">get_latest_for_server</span> <span class="ruby-comment">#To get the resource usage by the server </span>
  <span class="ruby-ivar">@apps_resource_usage</span> = <span class="ruby-constant">ResourceUsage</span>.<span class="ruby-identifier">get_latest_for_apps</span> <span class="ruby-comment"># to get the resource usage by the application</span>
  <span class="ruby-identifier">set_application_name</span>
<span class="ruby-keyword">end</span></pre>
            </div><!-- home-source -->
            
          </div>

          

          
        </div><!-- home-method -->

      
        <div id="index-method" class="method-detail ">
          <a name="method-i-index"></a>

          
          <div class="method-heading">
            <span class="method-name">index</span><span
              class="method-args">()</span>
            <span class="method-click-advice">click to toggle source</span>
          </div>
          

          <div class="method-description">
            
            <p>This action is to render the login page with the layout index.html.erb. If
the user session is already created the it redirects the control to the
home page of the admin panel.</p>
            

            
            <div class="method-source-code" id="index-source">
<pre>
<span class="ruby-comment"># File app/controllers/admin_controller.rb, line 32</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">index</span>
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">session</span>[<span class="ruby-value">:user</span>]
    <span class="ruby-identifier">redirect_to</span> <span class="ruby-identifier">home_path</span>
  <span class="ruby-keyword">else</span>
    <span class="ruby-ivar">@user</span> = <span class="ruby-constant">User</span>.<span class="ruby-identifier">new</span>
    <span class="ruby-identifier">render</span> <span class="ruby-value">:action</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-string">'index'</span>, <span class="ruby-value">:layout</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-string">'index'</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
            </div><!-- index-source -->
            
          </div>

          

          
        </div><!-- index-method -->

      
        <div id="login-method" class="method-detail ">
          <a name="method-i-login"></a>

          
          <div class="method-heading">
            <span class="method-name">login</span><span
              class="method-args">()</span>
            <span class="method-click-advice">click to toggle source</span>
          </div>
          

          <div class="method-description">
            
            <p>This action is called for login authentication. For user authentication it
used a method “user_authentication” present in the application.rb. It
takes user hash as a input from the login page.</p>
            

            
            <div class="method-source-code" id="login-source">
<pre>
<span class="ruby-comment"># File app/controllers/admin_controller.rb, line 66</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">login</span>
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">request</span>.<span class="ruby-identifier">post?</span>      
    <span class="ruby-identifier">rv</span> = <span class="ruby-constant">User</span>.<span class="ruby-identifier">authenticate</span>(<span class="ruby-identifier">params</span>[<span class="ruby-value">:user</span>][<span class="ruby-value">:name</span>], <span class="ruby-identifier">params</span>[<span class="ruby-value">:user</span>][<span class="ruby-value">:password</span>]) <span class="ruby-keyword">rescue</span> <span class="ruby-keyword">nil</span>      
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">rv</span> <span class="ruby-operator">==</span> <span class="ruby-keyword">true</span>
      <span class="ruby-identifier">session</span>[<span class="ruby-value">:session_time</span>] = <span class="ruby-constant">Time</span>.<span class="ruby-identifier">now</span>
      <span class="ruby-identifier">session</span>[<span class="ruby-value">:user</span>] = <span class="ruby-identifier">params</span>[<span class="ruby-value">:user</span>][<span class="ruby-value">:name</span>]
      <span class="ruby-identifier">flash</span>[<span class="ruby-value">:notice</span>] = <span class="ruby-keyword">nil</span>
      <span class="ruby-keyword">if</span> <span class="ruby-identifier">session</span>[<span class="ruby-value">:referer</span>]
        <span class="ruby-identifier">referer_path</span> = <span class="ruby-identifier">session</span>[<span class="ruby-value">:referer</span>]
        <span class="ruby-identifier">session</span>[<span class="ruby-value">:referer</span>] = <span class="ruby-keyword">nil</span>
        <span class="ruby-identifier">redirect_to</span> <span class="ruby-identifier">referer_path</span>
      <span class="ruby-keyword">else</span>
        <span class="ruby-identifier">redirect_to</span> <span class="ruby-identifier">root_path</span>      
      <span class="ruby-keyword">end</span>            
    <span class="ruby-keyword">else</span>
      <span class="ruby-identifier">flash</span>[<span class="ruby-value">:notice</span>] = <span class="ruby-identifier">rv</span>
      <span class="ruby-identifier">render</span> <span class="ruby-value">:action</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-string">'index'</span>, <span class="ruby-value">:layout</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-string">'index'</span>
    <span class="ruby-keyword">end</span>      
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
            </div><!-- login-source -->
            
          </div>

          

          
        </div><!-- login-method -->

      
        <div id="logout-method" class="method-detail ">
          <a name="method-i-logout"></a>

          
          <div class="method-heading">
            <span class="method-name">logout</span><span
              class="method-args">()</span>
            <span class="method-click-advice">click to toggle source</span>
          </div>
          

          <div class="method-description">
            
            <p>This function is for deleting the session of a user. By clearing the
session data for a specific user it delete the sesion of a user.</p>
            

            
            <div class="method-source-code" id="logout-source">
<pre>
<span class="ruby-comment"># File app/controllers/admin_controller.rb, line 89</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">logout</span>
  <span class="ruby-identifier">reset_session</span>
  <span class="ruby-identifier">flash</span>[<span class="ruby-value">:notice</span>] = <span class="ruby-constant">SUCCESSFUL_LOGOUT</span>
  <span class="ruby-identifier">redirect_to</span> <span class="ruby-identifier">root_path</span>
<span class="ruby-keyword">end</span></pre>
            </div><!-- logout-source -->
            
          </div>

          

          
        </div><!-- logout-method -->

      
        <div id="required_apps-method" class="method-detail ">
          <a name="method-i-required_apps"></a>

          
          <div class="method-heading">
            <span class="method-name">required_apps</span><span
              class="method-args">()</span>
            <span class="method-click-advice">click to toggle source</span>
          </div>
          

          <div class="method-description">
            
            <p>Used to paginate the list of deployed applications.</p>
            

            
            <div class="method-source-code" id="required_apps-source">
<pre>
<span class="ruby-comment"># File app/controllers/admin_controller.rb, line 152</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">required_apps</span>
  <span class="ruby-ivar">@info</span> = <span class="ruby-constant">YAML</span><span class="ruby-operator">::</span><span class="ruby-identifier">load_file</span>(<span class="ruby-constant">CONFIG_FILE_PATH</span>)   <span class="ruby-keyword">rescue</span> <span class="ruby-keyword">nil</span>
  <span class="ruby-ivar">@applications</span> = <span class="ruby-constant">App</span>.<span class="ruby-identifier">get_all</span>(<span class="ruby-identifier">params</span>[<span class="ruby-value">:page</span>] <span class="ruby-operator">||</span> <span class="ruby-value">1</span>)
  <span class="ruby-identifier">render</span> <span class="ruby-value">:update</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">page</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">page</span>.<span class="ruby-identifier">replace_html</span> <span class="ruby-string">'application_list_table'</span>, <span class="ruby-value">:partial</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-string">'application_table'</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
            </div><!-- required_apps-source -->
            
          </div>

          

          
        </div><!-- required_apps-method -->

      
        <div id="send_feedback-method" class="method-detail ">
          <a name="method-i-send_feedback"></a>

          
          <div class="method-heading">
            <span class="method-name">send_feedback</span><span
              class="method-args">()</span>
            <span class="method-click-advice">click to toggle source</span>
          </div>
          

          <div class="method-description">
            
            <p>this method is used to send the feedback</p>
            

            
            <div class="method-source-code" id="send_feedback-source">
<pre>
<span class="ruby-comment"># File app/controllers/admin_controller.rb, line 177</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">send_feedback</span>
  <span class="ruby-ivar">@fb</span> = <span class="ruby-identifier">feedback</span> = <span class="ruby-identifier">params</span>[<span class="ruby-value">:feedback</span>]
  <span class="ruby-identifier">message</span> = <span class="ruby-constant">MailSpecification</span>.<span class="ruby-identifier">validate_feedback_data</span>(<span class="ruby-identifier">feedback</span>)
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">message</span> <span class="ruby-operator">==</span> <span class="ruby-string">&quot;&quot;</span>
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">validate_captcha_answer</span>
      <span class="ruby-ivar">@fb</span> = {<span class="ruby-value">:name</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-string">&quot;&quot;</span> ,<span class="ruby-value">:email</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-string">&quot;&quot;</span>,<span class="ruby-value">:message</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-string">&quot;&quot;</span>}
      <span class="ruby-identifier">flash</span>[<span class="ruby-value">:notice</span>] = <span class="ruby-constant">Mailer</span>.<span class="ruby-identifier">send_feedback</span>(<span class="ruby-identifier">feedback</span>)
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">else</span>
    <span class="ruby-identifier">flash</span>[<span class="ruby-value">:notice</span>] = <span class="ruby-identifier">message</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-identifier">render</span> <span class="ruby-value">:partial</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-string">'feedback_partial'</span>
<span class="ruby-keyword">end</span></pre>
            </div><!-- send_feedback-source -->
            
          </div>

          

          
        </div><!-- send_feedback-method -->

      
        <div id="send_report_bug-method" class="method-detail ">
          <a name="method-i-send_report_bug"></a>

          
          <div class="method-heading">
            <span class="method-name">send_report_bug</span><span
              class="method-args">()</span>
            <span class="method-click-advice">click to toggle source</span>
          </div>
          

          <div class="method-description">
            
            <p>this method is used to report the bug</p>
            

            
            <div class="method-source-code" id="send_report_bug-source">
<pre>
<span class="ruby-comment"># File app/controllers/admin_controller.rb, line 192</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">send_report_bug</span>
  <span class="ruby-ivar">@rb</span> = <span class="ruby-identifier">report_bug</span> = <span class="ruby-identifier">params</span>[<span class="ruby-value">:report_bug</span>]
  <span class="ruby-identifier">message</span> = <span class="ruby-constant">MailSpecification</span>.<span class="ruby-identifier">validate_report_bug_data</span>(<span class="ruby-identifier">report_bug</span>)
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">message</span> <span class="ruby-operator">==</span> <span class="ruby-string">&quot;&quot;</span>
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">validate_captcha_answer</span>
      <span class="ruby-ivar">@rb</span> = {<span class="ruby-value">:name</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-string">&quot;&quot;</span> ,<span class="ruby-value">:email</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-string">&quot;&quot;</span>,<span class="ruby-value">:subject</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-string">&quot;&quot;</span>,<span class="ruby-value">:description</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-string">&quot;&quot;</span>}
      <span class="ruby-identifier">flash</span>[<span class="ruby-value">:notice</span>] = <span class="ruby-constant">Mailer</span>.<span class="ruby-identifier">send_report_bug</span>(<span class="ruby-identifier">report_bug</span>)
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">else</span>
    <span class="ruby-identifier">flash</span>[<span class="ruby-value">:notice</span>] = <span class="ruby-identifier">message</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-identifier">render</span> <span class="ruby-value">:partial</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-string">'report_bug_partial'</span>
<span class="ruby-keyword">end</span></pre>
            </div><!-- send_report_bug-source -->
            
          </div>

          

          
        </div><!-- send_report_bug-method -->

      
      </div><!-- public-instance-method-details -->
    
    </div><!-- 5Buntitled-5D -->
  

  </div><!-- documentation -->

  <div id="validator-badges">
    <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
    <p><small>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish
      Rdoc Generator</a> 2</small>.</p>
  </div>

</body>
</html>

